<template>
  <div id="YfChannelSearch">
    <el-row :gutter="30">
      <el-col :span="4">
        <el-input placeholder="请输入任务编码" v-model="taskId" clearable> </el-input>
      </el-col>
      <el-col :span="4">
        <el-input placeholder="请输入任务名称" v-model="taskName" clearable> </el-input>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" round @click.native="search()">查询</el-button>
      </el-col>
      <!--
      <el-col :span="1">
        <el-button type="success" round @click.native="addTask(false, {})"
          >新增</el-button
        >
      </el-col>
      -->
      <el-col :span="1.5">
        <el-button type="success" round @click.native="showSzWindow()">导出市占</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" round @click.native="addWeiziTask()">新增微子任务</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" round @click.native="addShushuoTask()">新增数说任务</el-button>
      </el-col>
    </el-row>
    <el-row>&nbsp;</el-row>
    <el-row>
      <el-table :data="tableData" border highlight-current-row style="width: 100%" v-loading="tableLoading">
        <el-table-column prop="id" label="任务编码" width="250"> </el-table-column>
        <el-table-column prop="taskName" label="任务名称" width="300"> </el-table-column>
        <!--
        <el-table-column prop="address" label="地址" width="200">
        </el-table-column> -->
        <el-table-column prop="taskType" label="任务类型" width="100" :formatter="taskTypeFormatter"> </el-table-column>
        <el-table-column prop="platformCode" label="平台" width="100"> </el-table-column>
        <el-table-column prop="statusDesc" label="状态" width="100"> </el-table-column>
        <el-table-column prop="createTime" label="创建时间" width="200" :formatter="dateFormatter"> </el-table-column>
        <el-table-column prop="creator" label="创建人" width="100"> </el-table-column>
        <el-table-column label="操作" width="350">
          <template slot-scope="scope">
            <!--
            <el-button
              @click="addTask(true, scope.row)"
              type="text"
              size="small"
              >详情</el-button
            >
            <el-button @click="editTask(scope.row)" type="text" size="small"
              >编辑</el-button
            >
            -->
            <el-button @click="listSubTask(scope.row)" type="text" size="small">查看进度</el-button>
            <template v-if="scope.row.isExport == 'N'">
              <el-button @click="exportData(scope.row)" type="text" size="small">开始数据导出</el-button>
            </template>
            <template v-if="scope.row.isExport == 'Y'">
              <el-button @click="exportData(scope.row)" type="text" size="small">重复数据导出</el-button>
            </template>
            <el-button @click="downloadSku(scope.row)" type="text" size="small">下载数据</el-button>
            <template v-if="scope.row.status == 'DRAFT'">
              <el-button @click="deleteTask(scope.row)" type="text" size="small">删除</el-button>
            </template>
            <template v-if="scope.row.status == 'INIT' || scope.row.status == 'RUNNING'">
              <el-button @click="confirmCancelTask(scope.row)" type="text" size="small"><font color="red">取消</font></el-button>
            </template>
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <el-row>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="curentPage"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-row>

    <AddWeiziTask :taskForm="taskForm" :addWzTaskVisible="addWweiziTaskVisible" @closeWeiziTaskWindow="closeWeiziTaskWindow"></AddWeiziTask>

    <AddShushuoTask :taskForm="taskForm" :addSsTaskVisible="addShushuoTaskVisible" @closeShushuoTaskWindow="closeShushuoTaskWindow"></AddShushuoTask>

    <el-dialog title="任务详情" :visible.sync="subTaskVisible" width="70%">
      <el-alert name="detailAlert" :title="detailInfo" type="info" :closable="detailInfoCloseable"></el-alert>
      <el-table :data="subTaskTableData" style="width: 100%">
        <el-table-column prop="cityName" label="城市" width="150"> </el-table-column>
        <el-table-column prop="storeName" label="门店名称" width="250"> </el-table-column>
        <el-table-column prop="statusDesc" label="状态" width="100"> </el-table-column>
        <el-table-column prop="platformCode" label="平台" width="100"> </el-table-column>
        <el-table-column prop="level" label="优先级" width="100"> </el-table-column>
        <el-table-column prop="beginTime" label="开始时间" width="100"> </el-table-column>
        <el-table-column prop="outTaskId" label="任务ID" width="100"> </el-table-column>
        <el-table-column prop="desc" label="描述"> </el-table-column>
        <el-table-column prop="ctl" label="操作"> </el-table-column>
      </el-table>
    </el-dialog>

    <el-dialog title="市占导出" :visible.sync="exportSzDialogVisible" width="40%" center>
      <el-row :gutter="30">
        <el-col :span="3">
          平台：
        </el-col>
        <el-col :span="10">
          <el-radio v-model="exportPlatformCode" label="MTWM">美团</el-radio>
          <el-radio v-model="exportPlatformCode" label="ELM">饿了么</el-radio>
        </el-col>
      </el-row>
      <el-row :gutter="30">
        <el-col :span="3">
          来源：
        </el-col>
        <el-col :span="10">
          <el-radio v-model="taskType" label="WEIZI">微子</el-radio>
          <el-radio v-model="taskType" label="SHUSHUO">数说</el-radio>
        </el-col>
      </el-row>
      <el-row :gutter="30">
        <el-col :span="3">
          日期：
        </el-col>
        <el-col :span="10">
          <el-date-picker
            v-model="dateRange"
            type="daterange"
            align="center"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions"
            value-format="yyyy-MM-dd"
            :default-time="['00:00:00', '23:59:59']"
          >
          </el-date-picker>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="exportWeiziSz">导出</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import Index from './index.js';
export default Index;
</script>
<style scoped>
.el-row {
  margin-bottom: 15px;
}
</style>
